const router = require('koa-router')() // 一边导入一边实例化
// const result = require('../../config/result.js')
// const { regcheck, checking } = require('../../config/checking.js')
const fs = require('fs');
const axios = require('axios');
// 操作数据库的接口
const { getToken, DownloadFileUrl } = require('../../config/databaseapi.js')
// 注册接口
router.post('/getfiletempurl', async (ctx) => {
    console.log('调用获取文件临时路径接口');
    // console.log(ctx.request.body);
    const file_list = [];
    for(let i=0;i<ctx.request.body.length;i++){
        const obj = {"fileid":ctx.request.body[i],"max_age":7200};
        file_list.push(obj);
    }
    const res = await new getToken().posteve4(DownloadFileUrl, file_list);
    console.log('返回结果',res);
    if(res.errcode===0 && res.errmsg==='ok'){
        ctx.body = {msg:"查询成功",status:1,data:res.file_list}
    }else{
        ctx.body = {msg:"查询失败",status:1,data:res.errmsg}
    }
});

module.exports = router.routes()